/*
 * Copyright (C), 2005-2018, 上海瑛麒动漫科技有限公司
 * FileName: RedissonLock.java
 * Author:   tianmu
 * Date:     2018年2月22日 下午5:32:24
 * Description: //模块目的、功能描述
 * History: //修改记录
 * <author>      <time>      <version>    <desc>
 * 修改人姓名             修改时间            版本号                  描述
 */
package com.sfang.common.redis.redisson;

import com.sfang.common.redis.sdk.RedisLock;
import org.redisson.api.RLock;
import org.redisson.api.RedissonClient;

import java.util.concurrent.TimeUnit;

/**
 * 〈一句话功能简述〉<br>
 * 〈功能详细描述〉
 *
 * @author tianmu
 * @see [相关类/方法]（可选）
 * @since [产品/模块版本] （可选）
 */
public class RedissonLock implements RedisLock {

    private final RLock rLock;

    public RedissonLock(RedissonClient redissonClient, String key) {
        rLock = redissonClient.getLock(key);
    }

    @Override
    public boolean expire(long timeToLive, TimeUnit timeUnit) {
        return false;//rLock.expire(timeToLive, timeUnit);
    }

    @Override
    public boolean expireAt(long timestamp) {
        return false;//rLock.expireAt(timestamp);
    }

    @Override
    public boolean isLocked() {
        return rLock.isLocked();
    }

    @Override
    public void lock() {
        rLock.lock();
    }

    @Override
    public void lock(long leaseTime, TimeUnit unit) {
        rLock.lock(leaseTime, unit);
    }

    @Override
    public boolean tryLock() {
        return rLock.tryLock();
    }

    @Override
    public boolean tryLock(long time, TimeUnit unit) throws InterruptedException {
        return rLock.tryLock(time, unit);
    }

    @Override
    public void unlock() {
        rLock.unlock();
    }

    @Override
    public boolean tryLock(long waitTime, long leaseTime, TimeUnit unit) throws InterruptedException {
        return rLock.tryLock(waitTime,leaseTime,unit);
    }

    @Override
    public boolean isHeldByCurrentThread() {
        return rLock.isHeldByCurrentThread();
    }

    @Override
    public String getName() {
        return rLock.getName();
    }

}
